import Vue from 'vue'
import numeral from 'numeral'
import {
	amount
} from '@/common/util'
Vue.filter('money', function(money, format = '0,0.00') {
	if (money === null) {
		return '0.00';
	}
	return `${numeral(money/100).format(format)}`;
})
Vue.filter('judge', function(item,memberType, format = '0,0.00') {
	let finallyPrice = 0;
	if(memberType==1||memberType==2){
		finallyPrice = `${numeral(item.svip_price/100).format(format)}`
	}else if(memberType==3){
		finallyPrice = `${numeral(item.vip_price/100).format(format)}`  
	}else{
		finallyPrice = `${numeral(item.sale_price/100).format(format)}`  
	}
	return Number(finallyPrice);
})


Vue.filter('timeStamp', function(timeStamp, format = '2019-01-01') {
	if (typeof timeStamp !== 'number' || timeStamp < 0) {
		return timeStamp
	}
	var date = new Date(timeStamp * 1000);
	var y = date.getFullYear();
	var m = date.getMonth() + 1;
	m = m < 10 ? ('0' + m) : m;
	var d = date.getDate();
	d = d < 10 ? ('0' + d) : d;
	var h = date.getHours();
	h = h < 10 ? ('0' + h) : h;
	var minute = date.getMinutes();
	var second = date.getSeconds();
	minute = minute < 10 ? ('0' + minute) : minute;
	second = second < 10 ? ('0' + second) : second;
	return `${y + '-' + m + '-' + d + ' ' + h + ':' + minute + ':' + second}`; //年月日时分秒
})
